import { deleteOrder, getOrderConfirm, setSubmitOrder,getOrderTime, ZFBPay, getOrder,getOrderAll } from '@/api/order/order'

const state = {
  // userKey: getUserKey()
}

const mutations = {

}

const actions = {
  deleteOrder({ commit }, orderSn) {
    return new Promise((resolve, reject) => {
      deleteOrder(orderSn)
        .then(response => {
          resolve(response)
        }).catch(error => {
        reject(error)
      })
    })
  },
  getOrderConfirm({ commit }) {
    return new Promise((resolve, reject) => {
      getOrderConfirm()
        .then(response => {
          resolve(response)
        }).catch(error => {
        reject(error)
      })
    })
  },
  setSubmitOrder({ commit }, query) {
    return new Promise((resolve, reject) => {
      setSubmitOrder(query)
        .then(response => {
          resolve(response)
        }).catch(error => {
        reject(error)
      })
    })
  },
  getOrderTime({ commit }, orderSn) {
    return new Promise((resolve, reject) => {
      getOrderTime(orderSn)
        .then(response => {
          resolve(response)
        }).catch(error => {
        reject(error)
      })
    })
  },
  ZFBPay({ commit }, orderSn) {
    return new Promise((resolve, reject) => {
      ZFBPay(orderSn)
        .then(response => {
          resolve(response)
        }).catch(error => {
        reject(error)
      })
    })
  },
  getOrder({ commit }, status) {
    return new Promise((resolve, reject) => {
      getOrder(status)
        .then(response => {
          resolve(response)
        }).catch(error => {
        reject(error)
      })
    })
  },
  getOrderAll({ commit }, ) {
    return new Promise((resolve, reject) => {
      getOrderAll()
        .then(response => {
          resolve(response)
        }).catch(error => {
        reject(error)
      })
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
